﻿namespace Trading.IBApi

open System
open System.Reactive.Linq

open com.ib.client 

module Price =
    let skipWhile predicate (source : IObservable<Tick>) = source.SkipWhile(fun tick -> predicate tick)
    let whenMoreThan x = skipWhile <| (<) x
    let whenLessThan x = skipWhile <| (>) x

    let ask source = source |> Observable.choose (function | AskPrice x -> Some(x) | _ -> None)
    let bid source = source |> Observable.choose (function | BidPrice x -> Some(x) | _ -> None)
